<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<title>高级查询</title> 
$!{include("import_js_css.html")}
$!{include("header.html")}
<link draggable="true" rel="stylesheet"
	href="${viewPath}/resources/css/statistics.css" />
<link draggable="true" rel="stylesheet"
	href="${assetsPath}/js/jquery/ui/jquery-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${viewPath}/resources/css/expression.css" />
<script type="text/javascript"
	src="${assetsPath}/js/jquery/ui/jquery-ui.min.js"></script>
<script type="text/javascript">
	$(function() {
		//下拉列表框
		$("#resporId").select2({
			width: "100px",
			minimumResultsForSearch: -1
		});
		
		$("#groupName").val("");
		$("#expression").val("");
		$("#expressionType").val("");
		$("#resporId").select2("val", "");
		$("#proName").val("");
		
		$("#tb_stratety").html("<tr><td style='width: 30px;'><input name='ds_selectAll' type='checkbox'></td><td style='width: 60px;'>序号</td><td>表达式</td></tr>");
		
		var count = $("input[name^='ds_name_']").length;
		
		var t = $("#tree");
		t = $.fn.zTree.init(t, setting, zNodes);
		
		$("#shu").find('div span').click(function(){
			var id = $(this).attr("id");
			id = id.substring(16, id.length);
			var con = $(this).text();
			var val = $("#hidden_expression_" + id).val();
			$("#groupName").val(con);
			$("#expression").val(val);
		});
		
		//点击生成表达式
		$("#btn_member_export").click(function(){
			//获得选择的条件名称
			var shuconn = $("#groupName").val().trim();
			//获得大于小于选择框的显示文字
			var selectconn = $("#resporId").find("option:selected").text().trim();
			//获得大于小于选择框符号
			var selectVal = $("#resporId").select2("val");
			//获得输入框的值
			var proconn = $("#proName").val().trim();
			//获得表达式的字段部分
			var expression = $("#expression").val().trim().replace(/[&\|\\\*^%$#@\-]/g,"");

			//条件不能为空
			if (expression == null || expression.length <= 0) {
				alert("请选择一个条件！")
				return;
			}
			
			//符号不能为空
			if (selectconn == null || selectconn.length <= 0) {
				alert("请选择一个比较符号！");
				return;
			}
			
			//组合表达式显示文字
			var bigconn = shuconn + selectconn + proconn;
			//组合表达式值
			var bigVal = expression + " " + selectVal + " " + proconn;
			
			//判断选择是否为空
			if (selectVal == "== nil" || selectVal == "!= nil") {
				//显示文字
				bigconn = shuconn + selectconn;
				//表达式
				if (selectVal == "== nil") {
					bigVal = expression + " " + selectVal + " || " + expression + " == \"\"";
				} else if (selectVal == "!= nil") {
					bigVal = expression + " " + selectVal + " && " + expression + " != \"\"";
				}
				
			} else if (selectVal == "string.contains") {
				//判断类型
				var type = $("#expressionType").val();
				if (type == "number") {
					proconn = proconn * 1;
				} else {
					proconn = "\"" + proconn + "\"";
				}
				bigconn = shuconn + selectconn + proconn;
				//判断是否为包含
				bigVal = "string.contains(" + expression + "," + proconn + ")";
			} else {
				if (proconn == null || proconn.length <= 0) {
					alert("请输入比较字符串！");
					return;
				}
				var proconn1 = "";
				//判断类型
				var type = $("#expressionType").val();
				if (type == "number") {
					proconn = proconn * 1;
				} else {
					if(type=="date"||type=="datetime"){
						proconn1 = "\"" +proconn.trim()+" 00:00:00:00"+ "\"";
						proconn = "\"" + proconn + "\"";
						bigconn = shuconn + selectconn + proconn;
						bigVal = expression + " " + selectVal + " " + proconn1;
					}else{
						proconn = "\"" + proconn + "\"";
						bigconn = shuconn + selectconn + proconn;
						bigVal = expression + " " + selectVal + " " + proconn;
					}
				}
			}
			
			count ++;
			$("#tb_stratety").append(
				"<tr id='ds_tr_" + count + "'>" + 
				"<td><input name='ds_name_" + count + "' type='checkbox'></td>" + 
				"<td><span>" + count + "<span></td>" + 
				"<td id='ds_td_" + count + "'><span>" + bigconn + "</span><p id='ds_condition_" + count + "'>" + bigVal + "</p></td>" + 
				"</tr>"
			);
		});
		
		//全选
		$("input[name='ds_selectAll']").click(function() {
			$("input[name^='ds_name_']").prop("checked", $(this).prop("checked"));
		});

		//同时满足
		$("#ds_fit_meanwhile").click(function() {
			var len = $("input[name^='ds_name_']:checked").length;
			if (len < 1) {
				alert("请选择一个表达式！");
				return;
			} else if (len == 1) {
				alert("请选择另一个表达式！");
				return;
			}
			var selDS = new Array();
			
			//记录选中的序号
			var stgText = new Array();
			$("input[name^='ds_name_']:checked").each(function() {
				var name = $(this).attr("name");
				var index = name.substring(8, name.length);
				//var text = $("#ds_td_" + index + " span").text().trim();
				stgText.push("满足条件" + index);
				//拼接表达式
				var strategy = $("p[id='ds_condition_" + index + "']").text();
				selDS.push("(" + strategy + ")");
			});
			var strategies = selDS.join(" && ");
			
			var text = stgText.join(" 且 ");
			count ++;
			$("#tb_stratety").append(
				"<tr id='ds_tr_" + count + "'>" + 
				"<td><input name='ds_name_" + count + "' type='checkbox'></td>" + 
				"<td><span>" + count + "<span></td>" + 
				"<td id='ds_td_" + count + "'><span>" + text + "</span><p id='ds_condition_" + count + "'>" + strategies + "</p></td>" + 
				"</tr>"
			);
		});
		
		//满足其一
		$("#ds_fit_oneMore").click(function() {
			var len = $("input[name^='ds_name_']:checked").length;
			if (len < 1) {
				alert("请选择一个表达式！");
				return;
			} else if (len == 1) {
				alert("请选择另一个表达式！");
				return;
			}
			var selDS = new Array();
			
			//记录选中的序号
			var stgText = new Array();
			$("input[name^='ds_name_']:checked").each(function() {
				var name = $(this).attr("name");
				var index = name.substring(8, name.length);
				stgText.push("满足条件" + index);
				
				//拼接表达式
				var strategy = $("p[id='ds_condition_" + index + "']").text();
				selDS.push("(" + strategy + ")");
			});
			var strategies = selDS.join(" || ");
			
			var text = stgText.join(" 或 ");
			count ++;
			$("#tb_stratety").append(
				"<tr id='ds_tr_" + count + "'>" + 
				"<td><input name='ds_name_" + count + "' type='checkbox'></td>" + 
				"<td><span>" + count + "<span></td>" + 
				"<td id='ds_td_" + count + "'><span>" + text + "</span><p id='ds_condition_" + count + "'>" + strategies + "</p></td>" + 
				"</tr>"
			);
		});
		
		//满足相反
		$("#ds_fit_contrary").click(function() {
			var len = $("input[name^='ds_name_']:checked").length;
			if (len < 1) {
				alert("请选择一个表达式！");
				return;
			} else if (len > 1) {
				alert("只可选择一个！");
				return;
			}
			var selDS = new Array();
			
			var stgText = new Array();
			$("input[name^='ds_name_']:checked").each(function() {
				//记录选中的序号
				var name = $(this).attr("name");
				var index = name.substring(8, name.length);
				stgText.push("不满足条件" + index);
				
				//拼接表达式
				var strategy = $("p[id='ds_condition_" + index + "']").text();
				selDS.push("!(" + strategy + ")");
			});
			
			var strategies = selDS.join(" && ");
			
			var text = stgText.join(" ");
			count ++;
			$("#tb_stratety").append(
				"<tr id='ds_tr_" + count + "'>" + 
				"<td><input name='ds_name_" + count + "' type='checkbox'></td>" + 
				"<td><span>" + count + "<span></td>" + 
				"<td id='ds_td_" + count + "'><span>" + text + "</span><p id='ds_condition_" + count + "'>" + strategies + "</p></td>" + 
				"</tr>"
			);
		});
		
		//删除
		$("#ds_fit_delete").click(function() {
			var len = $("input[name^='ds_name_']:checked").length;
			if (len < 1) {
				alert("请选择一个表达式！");
				return;
			}
			
			confirm("确定删除？", function() {
				$("input[name^='ds_name_']:checked").each(function() {
					var name = $(this).attr("name");
					var index = name.substring(8, name.length);
					
					//移除选择的tr
					$("#ds_tr_" + index).remove();
				});
				
				//全选按钮重置
				$("input[name='ds_selectAll']").prop("checked", false);
			});			
		});
		
		//点击查询按钮
		$("#ds_fit_search").click(function() {
			page = "string";
			getData(page);
		});
		
		//每页显示10条
		$("#ds_show_page_10").click(function() {
			getData(10);
		});
		
		//每页显示20条
		$("#ds_show_page_20").click(function() {
			getData(20);
		});
		
		//显示全部
		$("#ds_show_page_all").click(function() {
			page = "string";
			getData(page);
		});
		
		//切换tab
		$("#stat_info li").click(function() {
			var txt = $(this).text();
			
			//改变table显示内容
			if (txt == "会员") {
				var type = "sourceMember";
				
				$.post(
					"${basePath}/yueyogaAdmin/ajaxFindTreeByType.jhtml",
					{"type": type},
					function(response) {
						var res = eval("(" + response + ")");
						if (res.success) {
							var node = res.items;
							
							var setting = {
								view: {
									dblClickExpand: false,
									showLine: true,
									selectedMulti: false,
								},
								data :{
									key : {
										name:"text",
										children:"childNodes",
										url:"link"
									}
								},
							    callback: {
									onClick: zTreeOnClick
								} 
							};
							
							var t = $("#tree");
							t = $.fn.zTree.init(t, setting, node);
							//点击会员
							$("#exp_search_result").html("<tr class='tr-edit'><td>编号</td><td>姓名</td><td>手机号</td><td>信息来源</td><td>会籍顾问</td><td>负责人</td></tr>");
						} else {
							alert(res.msg);
						}
					}
				);
				
				$("#groupName").val("");
				$("#expression").val("");
				$("#expressionType").val("");
				$("#resporId").select2("val", "");
				$("#proName").val("");
				
				$("#tb_stratety").html("<tr><td style='width: 30px;'><input name='ds_selectAll' type='checkbox'></td><td style='width: 60px;'>序号</td><td>表达式</td></tr>");
			} else if (txt == "班级") {
				var type = "sourceClass";
				
				$.post(
					"${basePath}/yueyogaAdmin/ajaxFindTreeByType.jhtml",
					{"type": type},
					function(response) {
						var res = eval("(" + response + ")");
						if (res.success) {
							var node = res.items;
							
							var setting = {
								view: {
									dblClickExpand: false,
									showLine: true,
									selectedMulti: false,
								},
								data :{
									key : {
										name:"text",
										children:"childNodes",
										url:"link"
									}
								},
							    callback: {
									onClick: zTreeOnClick
								} 
							};
							
							var t = $("#tree");
							t = $.fn.zTree.init(t, setting, node);
							//点击班级
							$("#exp_search_result").html("<tr class='tr-edit'><td>名称</td><td>状态</td><td>负责人</td><td>老师</td><td>助教</td><td>场地</td><td>类型</td><td>开始时间</td><td>结束时间</td></tr>");
						} else {
							alert(res.msg);
						}
					}
				);
				
				$("#groupName").val("");
				$("#expression").val("");
				$("#expressionType").val("");
				$("#resporId").select2("val", "");
				$("#proName").val("");
				
				$("#tb_stratety").html("<tr><td style='width: 30px;'><input name='ds_selectAll' type='checkbox'></td><td style='width: 60px;'>序号</td><td>表达式</td></tr>");
			} else if (txt == "活动") {
				var type = "sourceliftclub";
				
				$.post(
					"${basePath}/yueyogaAdmin/ajaxFindTreeByType.jhtml",
					{"type": type},
					function(response) {
						var res = eval("(" + response + ")");
						if (res.success) {
							var node = res.items;
							
							var setting = {
								view: {
									dblClickExpand: false,
									showLine: true,
									selectedMulti: false,
								},
								data :{
									key : {
										name:"text",
										children:"childNodes",
										url:"link"
									}
								},
							    callback: {
									onClick: zTreeOnClick
								} 
							};
							
							var t = $("#tree");
							t = $.fn.zTree.init(t, setting, node);
							//点击活动
							$("#exp_search_result").html("<tr class='tr-edit'><td>主题</td><td>状态</td><td>老师</td><td>负责人</td><td>场地</td><td>开始时间</td><td>结束时间</td></tr>");
						} else {
							alert(res.msg);
						}
					}
				);
				
				$("#groupName").val("");
				$("#expression").val("");
				$("#expressionType").val("");
				$("#resporId").select2("val", "");
				$("#proName").val("");
				
				$("#tb_stratety").html("<tr><td style='width: 30px;'><input name='ds_selectAll' type='checkbox'></td><td style='width: 60px;'>序号</td><td>表达式</td></tr>");
			} else if (txt == "产品") {
				var type = "sourceProduct";
				
				$.post(
					"${basePath}/yueyogaAdmin/ajaxFindTreeByType.jhtml",
					{"type": type},
					function(response) {
						var res = eval("(" + response + ")");
						if (res.success) {
							var node = res.items;
							
							var setting = {
								view: {
									dblClickExpand: false,
									showLine: true,
									selectedMulti: false,
								},
								data :{
									key : {
										name:"text",
										children:"childNodes",
										url:"link"
									}
								},
							    callback: {
									onClick: zTreeOnClick
								} 
							};
							
							var t = $("#tree");
							t = $.fn.zTree.init(t, setting, node);
							//点击产品
							$("#exp_search_result").html("<tr class='tr-edit'><td>编号</td><td>名称</td><td>类型</td><td>价格(元)</td><td>次数</td><td>起始日期</td><td>结束日期</td></tr>");
						} else {
							alert(res.msg);
						}
					}
				);
				
				$("#groupName").val("");
				$("#expression").val("");
				$("#expressionType").val("");
				$("#resporId").select2("val", "");
				$("#proName").val("");
				
				$("#tb_stratety").html("<tr><td style='width: 30px;'><input name='ds_selectAll' type='checkbox'></td><td style='width: 60px;'>序号</td><td>表达式</td></tr>");
			} else if (txt == "商品") {
				var type = "sourceGoods";
				
				$.post(
					"${basePath}/yueyogaAdmin/ajaxFindTreeByType.jhtml",
					{"type": type},
					function(response) {
						var res = eval("(" + response + ")");
						if (res.success) {
							var node = res.items;
							
							var setting = {
								view: {
									dblClickExpand: false,
									showLine: true,
									selectedMulti: false,
								},
								data :{
									key : {
										name:"text",
										children:"childNodes",
										url:"link"
									}
								},
							    callback: {
									onClick: zTreeOnClick
								} 
							};
							
							var t = $("#tree");
							t = $.fn.zTree.init(t, setting, node);
							//点击商品
							$("#exp_search_result").html("<tr class='tr-edit'><td>编号</td><td>名称</td><td>类型</td><td>单价(元)</td><td>库存</td><td>装填</td><td>创建日期</td></tr>");
						} else {
							alert(res.msg);
						}
					}
				);
				
				$("#groupName").val("");
				$("#expression").val("");
				$("#expressionType").val("");
				$("#resporId").select2("val", "");
				$("#proName").val("");
				
				$("#tb_stratety").html("<tr><td style='width: 30px;'><input name='ds_selectAll' type='checkbox'></td><td style='width: 60px;'>序号</td><td>表达式</td></tr>");
			} else if (txt == "任务") {
				var type = "sourceTask";
				
				$.post(
					"${basePath}/yueyogaAdmin/ajaxFindTreeByType.jhtml",
					{"type": type},
					function(response) {
						var res = eval("(" + response + ")");
						if (res.success) {
							var node = res.items;
							
							var setting = {
								view: {
									dblClickExpand: false,
									showLine: true,
									selectedMulti: false,
								},
								data :{
									key : {
										name:"text",
										children:"childNodes",
										url:"link"
									}
								},
							    callback: {
									onClick: zTreeOnClick
								} 
							};
							
							var t = $("#tree");
							t = $.fn.zTree.init(t, setting, node);
							//点击任务
							$("#exp_search_result").html("<tr class='tr-edit'><td>工作安排</td><td>到期时间</td><td>会员编号</td><td>姓名</td><td>手机号</td><td>信息来源</td><td>会员状态</td><td>会员子状态</td><td>任务状态</td></tr>");
						} else {
							alert(res.msg);
						}
					}
				);
				
				$("#groupName").val("");
				$("#expression").val("");
				$("#expressionType").val("");
				$("#resporId").select2("val", "");
				$("#proName").val("");
				
				$("#tb_stratety").html("<tr><td style='width: 30px;'><input name='ds_selectAll' type='checkbox'></td><td style='width: 60px;'>序号</td><td>表达式</td></tr>");
			}
		});
	});
	
	function getData(page) {
		var len = $("input[name^='ds_name_']:checked").length;
		if (len < 1) {
			alert("请选择一个表达式！");
			return;
		} else if (len > 1) {
			alert("只可选择一个！");
			return;
		}
		var exp = "";
		$("input[name^='ds_name_']:checked").each(function() {
			//记录选中的序号
			var name = $(this).attr("name");
			var index = name.substring(8, name.length);
			
			//获得表达式
			exp = $("#ds_condition_" + index).text();
		});
		
		var d = wait("正在查询，请稍候");
		
		//判断是哪个tab
		var txt = $("#stat_info li[class='active']").text();
		var expType = "member";
		
		if (txt == "会员") {
			$("#exp_search_result").html("<tr class='tr-edit'><td>编号</td><td>姓名</td><td>手机号</td><td>信息来源</td><td>会籍顾问</td><td>负责人</td></tr>");
			//会员
			expType = "member";
			$.post(
				"${basePath}/yueyogaAdmin/ajaxAdvSearchMember.jhtml",
				{"expression": exp, "expType": expType, "limit": page},
				function(response) {
					var res = eval("(" + response + ")");
					if (res.success) {
						var size = parseInt(res.total);
						if (size<=0) {
							alert("未查找到数据！");
							return;
						}
						
						//会员
						for (var i = 0;i < size;i++) {
							var marketingsource = "";
							if(res.items[i].marketingsource == '81') {
								marketingsource = "电话打入";
							} else if (res.items[i].marketingsource == '82'){
								marketingsource = "主动拜访";
							} else if (res.items[i].marketingsource == '83'){
								marketingsource = "数据库";
							} else if (res.items[i].marketingsource == '84'){
								marketingsource = "线上活动";
							} else if (res.items[i].marketingsource == '85'){
								marketingsource = "线下活动";
							} else if (res.items[i].marketingsource == '86'){
								marketingsource = "其他";
							} else {
								marketingsource = "";
							}
							
							var keeperName = "";
							if (!(typeof(res.items[i].keeperName) == "undefined")) {
								keeperName = res.items[i].keeperName;
							}
							
							$("#exp_search_result").append(
								"<tr>" + 
								"<td><a href='${basePath}/yueyogaAdmin/toMemberDetail.jhtml?id=" + res.items[i].memberid + "'>" + res.items[i].memberid + "</a></td>" + 
								"<td><a href='${basePath}/yueyogaAdmin/toMemberDetail.jhtml?id=" + res.items[i].memberid + "'>" + res.items[i].name + "</a></td>" + 
								"<td>" + res.items[i].phone + "</td>" + 
								"<td>" + marketingsource + "</td>" + 
								"<td>" + keeperName + "</td>" + 
								"<td>" + res.items[i].fuzerenName + "</td>" + 
								"</tr>"
							);
						}
					}
				}
			);
			d.close().remove();
		}
		else if (txt == "班级") {
			$("#exp_search_result").html("<tr class='tr-edit'><td>名称</td><td>状态</td><td>负责人</td><td>老师</td><td>助教</td><td>场地</td><td>类型</td><td>开始时间</td><td>结束时间</td></tr>");
			//班级
			expType = "clazz";
			$.post(
				"${basePath}/yueyogaAdmin/ajaxAdvSearchClazz.jhtml",
				{"expression": exp, "expType": expType, "limit": page},
				function(response) {
					var res = eval("(" + response + ")");
					if (res.success) {
						var size = parseInt(res.total);
						if (size<=0) {
							alert("未查找到数据！");
							return;
						}
						
						for (var i = 0;i < size;i++) {
							var st = res.items[i].startTime;
							var et = res.items[i].endTime;
							if (typeof(st) == "undefined")
								st = "";
							if (typeof(et) == "undefined")
								et = "";
							$("#exp_search_result").append(
								"<tr>" + 
								"<td><a href='${basePath}/yueyogaAdmin/viewClass.jhtml?classId=" + res.items[i].id + "'>" + res.items[i].name + "</a></td>" + 
								"<td>" + res.items[i].state + "</td>" + 
								"<td>" + res.items[i].officer + "</td>" + 
								"<td>" + res.items[i].mainTeachers + "</td>" + 
								"<td>" + res.items[i].assistants + "</td>" + 
								"<td>" + res.items[i].places + "</td>" + 
								"<td>" + res.items[i].type + "</td>" + 
								"<td>" + st + "</td>" + 
								"<td>" + et + "</td>" + 
								"</tr>"
							);
						}
					}
				}
			);
			d.close().remove();
		}
		else if (txt == "活动") {
			$("#exp_search_result").html("<tr class='tr-edit'><td>主题</td><td>状态</td><td>老师</td><td>负责人</td><td>场地</td><td>开始时间</td><td>结束时间</td></tr>");
			//活动
			expType = "liftclub";
			$.post(
				"${basePath}/yueyogaAdmin/ajaxAdvSearchLiftClub.jhtml",
				{"expression": exp, "expType": expType, "limit": page},
				function(response) {
					var res = eval("(" + response + ")");
					if (res.success) {
						var size = parseInt(res.total);
						if (size<=0) {
							alert("未查找到数据！");
							return;
						}
						
						for (var i = 0;i < size;i++) {
							//活动状态
							var sta = res.items[i].status;
							sta = sta * 1;
							var status = "";
							if (sta == 0)
								status = "准备中";
							else if (sta == 1)
								status = "进行中";
							else if (sta == 2)
								status = "活动结束";
							else if (sta == 3)
								status = "活动取消";
							
							//活动负责人
							var username = "";
							var tempUsername = res.items[i].yudname;
							if (tempUsername == null || tempUsername.length <= 0)
								username = res.items[i].username;
							else
								username = res.items[i].yudname;
							
							//活动时间
							var sd = res.items[i].startdate;
							var ed = res.items[i].enddate;
							if (sd != null && sd.length > 0) {
								sd = sd.substring(0, 16);
							}
							if (ed != null && ed.length > 0) {
								ed = ed.substring(0, 16);
							}
							
							$("#exp_search_result").append(
								"<tr>" + 
								"<td><a href='${basePath}/yueyogaAdmin/toLiftClubDetail.jhtml?id=" + res.items[i].id + "'>" + res.items[i].name + "</a></td>" + 
								"<td>" + status + "</td>" + 
								"<td>" + res.items[i].co0name + "</td>" + 
								"<td>" + username + "</td>" + 
								"<td>" + res.items[i].placename + "</td>" + 
								"<td>" + sd + "</td>" +
								"<td>" + ed + "</td>" + 
								"</tr>"
							);
						}
					}
				}
			);
			d.close().remove();
		}
		else if (txt == "产品") {
			$("#exp_search_result").html("<tr class='tr-edit'><td>编号</td><td>名称</td><td>类型</td><td>价格(元)</td><td>次数</td><td>起始日期</td><td>结束日期</td></tr>");
			//产品
			expType = "product";
			$.post(
				"${basePath}/yueyogaAdmin/ajaxAdvSearchProducts.jhtml",
				{"expression": exp, "expType": expType, "limit": page},
				function(response) {
					var res = eval("(" + response + ")");
					if (res.success) {
						var size = parseInt(res.total);
						if (size<=0) {
							alert("未查找到数据！");
							return;
						}
						
						for (var i = 0;i < size;i++) {
							var count = res.items[i].counts;
							if (typeof(count) == "undefined")
								count = 0;
							
							//1:数量,2:按时间,3:年卡,4:季卡,5:月卡,6:半月卡,7:按金额,8:普通消费
							var type = res.items[i].type;
							if (type == "101") {
								type = "次卡";
							} else if (type == "102") {
								type = "按时间";
							} else if (type == "103") {
								type = "年卡";
							} else if (type == "104") {
								type = "季卡";
							} else if (type == "105") {
								type = "月卡";
							} else if (type == "106") {
								type = "半月卡";
							} else if (type == "107") {
								type = "按金额";
							} else if (type == "108") {
								type = "普通消费";
							}
							
							$("#exp_search_result").append(
								"<tr>" + 
								"<td>" + res.items[i].productId + "</td>" + 
								"<td><a href='${basePath}/yueyogaAdmin/toProductDetails.jhtml?productId=" + res.items[i].productId + "'>" + res.items[i].name + "</a></td>" + 
								"<td>" + type + "</td>" + 
								"<td>" + res.items[i].price + "</td>" + 
								"<td>" + count + "</td>" + 
								"<td>" + res.items[i].strBeginTime + "</td>" +
								"<td>" + res.items[i].strEndTime + "</td>" +
								"</tr>"
							);
						}
					}
				}
			);
			d.close().remove();
		}
		else if (txt == "商品") {
			$("#exp_search_result").html("<tr class='tr-edit'><td>编号</td><td>名称</td><td>类型</td><td>单价(元)</td><td>库存</td><td>装填</td><td>创建日期</td></tr>");
			//商品
			expType = "goods";
			$.post(
				"${basePath}/yueyogaAdmin/ajaxAdvSearchGoods.jhtml",
				{"expression": exp, "expType": expType, "limit": page},
				function(response) {
					var res = eval("(" + response + ")");
					if (res.success) {
						var size = parseInt(res.total);
						if (size<=0) {
							alert("未查找到数据！");
							return;
						}
						
						for (var i = 0;i < size;i++) {
							$("#exp_search_result").append(
								"<tr>" + 
								"<td>" + res.items[i].code + "</td>" + 
								"<td>" + res.items[i].name + "</td>" + 
								"<td>" + res.items[i].goodType.name + "</td>" + 
								"<td>" + res.items[i].price + "</td>" + 
								"<td>" + res.items[i].counts + "</td>" + 
								"<td>" + res.items[i].statusName + "</td>" +
								"<td>" + res.items[i].createtime + "</td>" +
								"</tr>"
							);
						}
					}
				}
			);
			d.close().remove();
		}
		else if (txt == "任务") {
			$("#exp_search_result").html("<tr class='tr-edit'><td>工作安排</td><td>到期时间</td><td>会员编号</td><td>姓名</td><td>手机号</td><td>信息来源</td><td>会员状态</td><td>会员子状态</td><td>任务状态</td></tr>");
			//任务
			expType = "task";
			$.post(
				"${basePath}/yueyogaAdmin/ajaxAdvSearchTasks.jhtml",
				{"expression": exp, "expType": expType, "limit": page},
				function(response) {
					var res = eval("(" + response + ")");
					if (res.success) {
						var size = parseInt(res.total);
						if (size<=0) {
							alert("未查找到数据！");
							return;
						}
						
						for (var i = 0;i < size;i++) {
							//信息来源
							var source = res.items[i].xxly;
							if (typeof(source) == "undefined")
								source = "";
							
							if(source == '81') {
								source = "电话打入";
							} else if (source == '82'){
								source = "主动拜访";
							} else if (source == '83'){
								source = "数据库";
							} else if (source == '84'){
								source = "线上活动";
							} else if (source == '85'){
								source = "线下活动";
							} else if (source == '86'){
								source = "其他";
							} else {
								source = "";
							}
							
							//会员状态
							var zt = res.items[i].hyzt;
							if (typeof(zt) == "undefined")
								zt = "";
							
							//会员子状态
							var zzt = res.items[i].hyzzt;
							if (typeof(zzt) == "undefined")
								zzt = "";
							
							$("#exp_search_result").append(
								"<tr>" + 
								"<td><a href='${basePath}/yueyogaAdmin/toViewTask.jhtml?id=" + res.items[i].rwbh + "'>" + res.items[i].gzap + "</a></td>" + 
								"<td>" + res.items[i].dqsj + "</a></td>" + 
								"<td>" + res.items[i].hykh + "</td>" + 
								"<td>" + res.items[i].hyxm + "</td>" + 
								"<td>" + res.items[i].hysjh + "</td>" + 
								"<td>" + source + "</td>" +
								"<td>" + zt + "</td>" +
								"<td>" + zzt + "</td>" + 
								"<td>" + res.items[i].rwzt + "</td>" + 
								"</tr>"
							);
						}
					}
				}
			);
			d.close().remove();
		}
	}
</script>
</head>
<body style="background-color: #fff;">
	<div id="drag_container" class="container menu_all">
		<div class="row-fluid drag-ctr-info panel-radius-stat">
			<div class="span12">
				<div class="tabbable">
					<ul id="stat_info" class="nav nav-tabs">
						<li class="active"><a href="#panel-member" data-toggle="tab">会员</a></li>
						<li><a href="#panel-clazz" data-toggle="tab">班级</a></li>
						<li><a href="#panel-liftClub" data-toggle="tab">活动</a></li>
						<li><a href="#panel-product" data-toggle="tab">产品</a></li>
						<li><a href="#panel-goods" data-toggle="tab">商品</a></li>
						<li><a href="#panel-task" data-toggle="tab">任务</a></li>
					</ul>
				</div>
				
				<div class="span12">
					<table>
						<tr>
							<td id="expression_conditions">
								<div id="ec_div" class="div_search_result" style="margin-top: 17px;">
									<div id="shu" style="border:1px solid #CCC; min-height: 241px;">
									 	<div class="typeList">
											<ul id="tree" class="ztree" style="width:180px; margin-top:1px;"></ul>
										</div>
									</div>
								</div>
								
								<script type="text/javascript">
									var zNodes = eval('[$!{tree}]');
									function zTreeOnClick(event, treeId, treeNode) {
										if(treeNode.expression == "" || treeNode.expression == null){
											$("#groupName").val("");
											$("#expression").val("");
											$("#expressionType").val("");
										}else{
												var val = treeNode.text;
												var parent = treeNode.getParentNode();
												while(parent.text!="查询条件"){
											        val = parent.text +"-"+ val;
											        parent = parent.getParentNode();
												}
												$("#groupName").val(val);
												$("#expression").val(treeNode.expression);
											    $("#expressionType").val(treeNode.valueType);
										}
										//提示
										var type = treeNode.valueType;
										if (type == "number") {
											$("#proNameTint").text("请输入数字");
										} else if (type == "string") {
											$("#proNameTint").text("请输入字符串");
										} else if (type == "datetime") {
											$("#proNameTint").text("格式：2014-01-01");
										} else if (type == "date") {
											$("#proNameTint").text("格式：2014-01-01");
										} else if (type == "time") {
											$("#proNameTint").text("格式：12:12:12");
										}
									}
									
									var setting = {
										view: {
											dblClickExpand: false,
											showLine: true,
											selectedMulti: false,
										},
										data :{
											key : {
												name:"text",
												children:"childNodes",
												url:"link"
											}
										},
									    callback: {
											onClick: zTreeOnClick
										} 
									};
								</script>
							</td>
					
							<td>
								<div class="panel" style="width: 860px !important; vertical-align: top;">
									<!-- 创建表达式区域start -->
									<div class="div_search_result">
										<input readonly type="text" class="form-control" name="name" id="groupName" style="width:200px; float:left; margin-top:6px;">
										<input id="expression" type="hidden">
										<input id="expressionType" type="hidden">
										<select id="resporId" name="resporId" style="float:left; margin-top:6px; margin-left:20px; width:80px;">
											<option value=""> </option>
											<option value=">">大于</option>
											<option value="<">小于</option>
											<option value="==">等于</option>
											<option value=">=">大于等于</option>
											<option value="<=">小于等于</option>
											<option value="!=">不等于</option>
											<option value="== nil">为空</option>
											<option value="!= nil">不为空</option>
											<!-- string.contains("", "") -->
											<option value="string.contains">包含</option>
										</select>
										<input type="text" class="form-control" id="proName" style="width:200px; float:left; margin-top:6px; margin-left:20px;">
										<div id="proNameTint" style="float: left; height: 100%; margin-left: 5px; line-height: 40px; text-align: left;"></div>
										<button id="btn_member_export" type="button" class="btn btn-default panel-radius-all" style="margin-top:6px; margin-left:20px;">保存</button>
									</div>
									<div style="clear:both;"></div>
									<!-- 创建表达式区域end -->
									
									<!-- 表达式组合区域start -->
									<div class="div_search_result">
										<div class="panel-heading panel-result panel-result-title">
											<h3 class="panel-title">表达式</h3>
											<div class="btn-group btn-gp-default">
												<button id="ds_fit_meanwhile" type="button" class="btn btn-default panel-radius-left">同时满足</button>
												<button id="ds_fit_oneMore" type="button" class="btn btn-default panel-radius-none">满足其一</button>
												<button id="ds_fit_contrary" type="button" class="btn btn-default panel-radius-none">满足相反</button>
												<button id="ds_fit_delete" type="button" class="btn btn-default panel-radius-none">删除</button>
												<div class="btn-group">
													<button id="ds_fit_search" type="button" class="btn btn-default panel-radius-none">查询</button>
													<button type="button" class="btn btn-default panel-radius-right dropdown-toggle" data-toggle="dropdown">
														<span class="caret"></span>
														<span class="sr-only">Toggle Dropdown</span>
													</button>
													<ul class="dropdown-menu">
														<li id="ds_show_page_10"><a href="javascript:void(0);">显示10条</a></li>
														<li id="ds_show_page_20"><a href="javascript:void(0);">显示20条</a></li>
														<li id="ds_show_page_all"><a href="javascript:void(0);">显示全部</a></li>
													</ul>
												</div>
											</div>
										</div>
										
										<table id="tb_stratety" class="table table-bordered table-hover table-condensed tb" style="text-align: center;">
											<tr>
												<td style="width: 30px;">
													<input name="ds_selectAll" type="checkbox">
												</td>
												<td style="width: 60px;">序号</td>
												<td>表达式</td>
											</tr>
										</table>
									</div>
									<!-- 表达式组合区域end -->
								</div>
							</td>
						</tr>
					</table>
				</div>
				
				
				
				<div id="stat_list" class="panel-radius-stat">
					<div class="panel-heading panel-result panel-result-title">
						<h3 class="panel-title">查询结果</h3>
					</div>
					<div>
						<table id="exp_search_result" class="table table-bordered table-hover table-condensed" style="text-align: center;">
							<tr class="tr-edit">
								<td>编号</td>
								<td>姓名</td>
								<td>手机号</td>
								<td>信息来源</td>
								<td>会籍顾问</td>
								<td>负责人</td>
							</tr>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>